//解密算法

public class Decrypt {
     String decrypt(String miwen,int miyao) throws exp1Exception {
        char[] c = miwen.toCharArray();
        int b = c.length;
        for(int i=0;i<b;i++) {
                if ((c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z')) {     //判断是否为英文字母

                    if(c[i] >= 'a' && c[i] <='z') {
                        int n = c[i] - 'a' - miyao;  //解密
                        if (n < 0) {
                            n = n + 26;
                        }
                        int mima = n % 26 + 'a';
                        c[i] = (char) mima;
                    }
                    else {
                        int m = c[i] - 'A' - miyao;
                        if (m < 0) {
                            m = m + 26;
                        }
                        int mima = m % 26 + 'A';
                        c[i] = (char) mima;
                    }
                }
                else {
                    throw new exp1Exception(miwen);
                }
        }
        return new String(c);   //返回明文
    }
}

